# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-other
pkgname=qca
pkgver=2.3.8
pkgrel=0
pkgdesc="Qt cryptographic architecture"
url="https://userbase.kde.org/QCA"
arch="all"
license="LGPL-2.1-or-later"
depends_dev="
	cyrus-sasl-dev
	qt5-qtbase-dev
	"
makedepends="$depends_dev
	cmake
	doxygen
	graphviz
	openssl-dev>3
	qt6-qt5compat-dev
	qt6-qtbase-dev
	samurai
	"
subpackages="$pkgname-qt6-dev:dev_qt6 $pkgname-dev $pkgname-doc lib$pkgname-qt5:libs_qt5 lib$pkgname-qt6:libs_qt6"
_repo_url="https://invent.kde.org/libraries/qca.git"
source="https://download.kde.org/stable/qca/$pkgver/qca-$pkgver.tar.xz"

build() {
	cmake -B build-qt5 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_cyrus-sasl_PLUGIN=yes \
		-DQT6=OFF
	cmake -B build-qt6 -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_cyrus-sasl_PLUGIN=yes \
		-DQT6=ON

	cmake --build build-qt5
	cmake --build build-qt6
}

check() {
	ctest --test-dir build-qt5 --output-on-failure
	ctest --test-dir build-qt6 --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build-qt5
	DESTDIR="$pkgdir" cmake --install build-qt6
}

dev_qt6() {
	depends="
		cyrus-sasl-dev
		qt6-qt5compat-dev
		qt6-qtbase-dev
		"
	amove usr/include/Qca-qt6
	amove usr/lib/cmake/Qca-qt6
	amove usr/lib/libqca-qt6.so
}

libs_qt5() {
	amove usr/lib/qca-qt5
	amove usr/lib/libqca*qt5*
}

libs_qt6() {
	amove usr/lib/qca-qt6
	amove usr/lib/libqca*qt6*
}

sha512sums="
ddb410214e8264955c2bb8c68d018e3826cb8ec48f8cc7207c2aec1c36051dc0501455b5049eff927dcf354603c0646f86ca10f2cebebe87789b3fd07a993b68  qca-2.3.8.tar.xz
"
